package com.itheima.d6Regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexDemo3 {
    public static void main(String[] args) {
        String rs = "来黑马学18842669584 联系邮箱771597183@qq.com";
        // 我们想把这段文字中的电话号码 和邮箱爬取出来
        //1 定义规则
        String regex = "(\\w{1,}@[a-z]{2,}(\\.[a-z]{2,}){1,2})|(1{1}[3-9]\\d{9})";
        //2 把规则编译成匹配对象
        Pattern compile = Pattern.compile(regex);
        // 3. 得到一个匹配器
        Matcher matcher = compile.matcher(rs);

        while (matcher.find()){
            String group = matcher.group();
            System.out.println(group);
        }
    }
}
